package com.bolehui.base.utils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @author chendongjie     email:chendongjie@gz.iscas.ac.cn
 * @version 1.0
 * @ClassName LogUtil
 * @Description
 * @createTime 2024/12/9 15:57
 * Copyright (C) 2021-2022 CASEEDER, All Rights Reserved.
 * 注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的
 */
public class LogUtil {

    private static final String DEBUG = "debug";
    private static final String INFO = "info";
    private static final String WARN = "warn";
    private static final String ERROR = "error";
    private static final String FATAL = "fatal";

    private static Log debugLog = LogFactory.getLog(DEBUG);
    private static Log infoLog = LogFactory.getLog(INFO);
    private static Log warnLog = LogFactory.getLog(WARN);
    private static Log errorLog = LogFactory.getLog(ERROR);
    private static Log fatalLog = LogFactory.getLog(FATAL);

    public static boolean isDebugEnabled(){
        return debugLog.isDebugEnabled();
    }

    public static boolean isInfoEnabled(){
        return infoLog.isInfoEnabled();
    }

    public static boolean isErrorEnabled(){
        return errorLog.isErrorEnabled();
    }

    public static boolean isWarnEnabled(){
        return warnLog.isWarnEnabled();
    }

    public static boolean isFatalEnabled(){
        return fatalLog.isFatalEnabled();
    }

    public static void debug(Object debug) {
        debug(debug, null);
    }

    public static void debug(Throwable t) {
        debug(t.getMessage(), t);
    }

    public static void debug(Object debug, Throwable t) {
        debugLog.debug(debug, t);
    }

    public static void info(Object info) {
        info(info, null);
    }

    public static void info(Throwable t) {
        info(t.getMessage(), t);
    }

    public static void info(Object info, Throwable t) {
        infoLog.info(info, t);
    }

    public static void warn(Throwable t) {
        warn(t.getMessage(), t);
    }

    public static void warn(Object warn) {
        warn(warn, null);
    }

    public static void warn(Object warn, Throwable t) {
        warnLog.warn(warn, t);
    }

    public static void error(Throwable t) {
        error(t.getMessage(), t);
    }

    public static void error(Object error) {
        error(error, null);
    }

    public static void error(Object error, Throwable t) {
        errorLog.error(error, t);
    }

    public static void fatal(Throwable t) {
        fatal(t.getMessage(), t);
    }

    public static void fatal(Object fatal) {
        fatal(fatal, null);
    }

    public static void fatal(Object fatal, Throwable t) {
        fatalLog.fatal(fatal, t);
    }

}
